package org.jeecg.modules.zcgl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.modules.zcgl.entity.AssetInfoSub;
import org.jeecg.modules.zcgl.mapper.AssetInfoSubMapper;
import org.jeecg.modules.zcgl.service.IAssetInfoSubService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Description: 资产明细
 * @Author: jeecg-boot
 * @Date:   2020-06-19
 * @Version: V1.0
 */
@Service
public class AssetInfoSubServiceImpl extends ServiceImpl<AssetInfoSubMapper, AssetInfoSub> implements IAssetInfoSubService {

	@Autowired
	private AssetInfoSubMapper assetInfoSubMapper;

	@Override
	public List<AssetInfoSub> selectByMainId(String mainId) {
		return assetInfoSubMapper.selectByMainId(mainId);
	}

	@Override
	public int selectCountByMainId(String mainId) {
		return baseMapper.selectCountByMainId(mainId);
	}

	@Override
	public int selectCountByMainIdAndIds(String mainId, String ids) {
		LambdaQueryWrapper<AssetInfoSub> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(AssetInfoSub::getAssetInfoId, mainId);
		queryWrapper.in(AssetInfoSub::getId, ids.split(CommonConstant.DEFAULT_SEPARATOR));
		return baseMapper.selectCount(queryWrapper);
	}

	@Override
	public List<AssetInfoSub> selectByMainIdAndIds(String mainId, String ids) {
		LambdaQueryWrapper<AssetInfoSub> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(AssetInfoSub::getAssetInfoId, mainId);
		queryWrapper.in(AssetInfoSub::getId, ids.split(CommonConstant.DEFAULT_SEPARATOR));
		return baseMapper.selectList(queryWrapper);
	}

	@Override
	public BigDecimal queryTotalAreaByIds(String ids) {
		return baseMapper.queryTotalAreaByIds(ids);
	}

	@Override
	public Integer selectCountByRoomStatus(Integer status, String assetInfoId) {
		return baseMapper.selectCountByRoomStatus(status, assetInfoId);
	}

}
